home *** CD-ROM | disk | FTP | other *** search
- Path: lori.albany.net!usenet
- From: sb0781@albany.net (Stephen Behnfeldt)
- Newsgroups: comp.lang.c++
- Subject: Dynamically allocated interrupt handlers?
- Date: Thu, 21 Mar 1996 01:37:30 GMT
- Organization: AlbanyNet - E-mail info@albany.net
- Message-ID: <4iqbv5$mqd@lori.albany.net>
- NNTP-Posting-Host: pm3ip20-albny.albany.net
- X-Newsreader: Forte Free Agent v0.55
-
- I am building a SerialPort class to model the serial ports on my PC.
- Associated with each instance of this class are elements such as an
- input character buffer and a hardware address - data members which
- will be unique to each instance.
-
- I am also trying to code the interrupt handler which will be
- associated with this class. While most of the code will be the same
- for each instance, the handler will have to know things like the
- hardware address and the location of the IO buffer for whichever port
- is generating the interrupt.
-
- I don't believe I can use a switch statement within the handler. I
- can't write
- switch ( port ) { ... }
- to determine the instance-specific data, since the handler won't know
- which port generated the interrupt, unless that port can update a
- register or some global variable, which it could only do from within
- the handler, right? So it seems like each handler will have to be
- distinct - one for each instance of the class.
-
- Now, since I only have two serial ports, I could individually code two
- handlers, initializing each one with the appropriate values at the
- appropriate time - probably during the constructor or a member
- function fo the form SerialPort::Open( ).
-
- However, it got me to wondering....
-
- If I were writing a similar class for other hardware of an
- indeterminate number, is it possible to dynamically allocate the
- handler? I could (theoretically) either use malloc( ), or somehow
- define the class to have distinct code for the handler. I have been
- playing around with the static keyword, but so far to no avail.
-
- Is this sort of situation common? I couldn't find an answer in the
- c.l.c FAQ list; I couldn't locate the C++ FAQ list on the Web; and I
- haven't been able to FTP the FAQ list from MIT, evidently because my
- PC barfs when WS_FTP tries to download a file whose name includes "+".
-
-
- TIA,
-
-
- --spb
-
-
-